<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <link rel="shortcut icon" type="image/ico" href="favicon.ico" />
  <title>SlickGrid example: jQuery Accordion with a grid in each pane</title>
  <link rel="stylesheet" href="../slick.grid.css" type="text/css"/>
  <link rel="stylesheet" href="../css/smoothness/jquery-ui-1.11.3.custom.css" type="text/css"/>
  <link rel="stylesheet" href="examples.css" type="text/css"/>
  <style>
  #myGrid01, #myGrid02 {
	background: white;
	outline: 0;
	border: 1px solid gray;
  }
  </style>
</head>
<body>
<table width="100%">
  <tr>
    <td valign="top" width="50%">
		<div id="accordion">
		  <h3 id="acc_sect1"><a href="#">Section 1</a></h3>
		  <div>
			<div id="myGrid01" style="width:600px;height:300px;"></div>
		  </div>
		  <h3 id="acc_sect2"><a href="#">Section 2</a></h3>
		  <div>
			<div id="myGrid02" style="width:600px;height:300px;"></div>
		  </div>
		</div>
	</td>
    <td valign="top">
      <h2>Demonstrates:</h2>
      <ul>
        <li>jQuery Accordion containing a grid in each pane</li>
      </ul>
        <h2>View Source:</h2>
        <ul>
            <li><A href="https://github.com/6pac/SlickGrid/blob/master/examples/example1-simple.html" target="_sourcewindow"> View the source for this example on Github</a></li>
        </ul>
    </td>
  </tr>
</table>

<script src="../lib/jquery-1.11.2.min.js"></script>
<script src="../lib/jquery-ui-1.11.3.min.js"></script>
<script src="../lib/jquery.event.drag-2.3.0.js"></script>

<script src="../slick.core.js"></script>
<script src="../slick.grid.js"></script>

<script>
  var grid01, grid02;
  var columns = [
    {id: "title", name: "Title", field: "title"},
    {id: "duration", name: "Duration", field: "duration"},
    {id: "%", name: "% Complete", field: "percentComplete"},
    {id: "start", name: "Start", field: "start"},
    {id: "finish", name: "Finish", field: "finish"},
    {id: "effort-driven", name: "Effort Driven", field: "effortDriven"},
    {id: "title", name: "Title", field: "title"},
    {id: "duration", name: "Duration", field: "duration"},
    {id: "%", name: "% Complete", field: "percentComplete"},
    {id: "start", name: "Start", field: "start"},
    {id: "finish", name: "Finish", field: "finish"},
    {id: "effort-driven", name: "Effort Driven", field: "effortDriven"}
  ];

  var options = {
    enableCellNavigation: true,
    enableColumnReorder: false
  };

  function CreateData() {
    var data = [];
    for (var i = 0; i < 500; i++) {
      data[i] = {
        title: "Task " + i,
        duration: "5 days",
        percentComplete: Math.round(Math.random() * 100),
        start: "01/01/2009",
        finish: "01/05/2009",
        effortDriven: (i % 5 == 0)
      };
    }
	return data;
  }
  
  $(function () {
    $( "#accordion" ).accordion(
	// Workaround for IE 7-9 issue where div is blank after switching panels - need to destroy and recreate grid
	//{
	//	activate: function( event, ui ) {
	//		var accHeaderId = '';
	//		if (ui.newHeader && ui.newHeader.length>0) { accHeaderId = ui.newHeader[0].id; }
	//		if (accHeaderId == 'acc_sect1') {
	//			grid01.destroy();
	//			grid01 = new Slick.Grid("#myGrid01", data01, columns, options);
	//		}
	//	}
	//}
	);	

    var data01 = CreateData();
    grid01 = new Slick.Grid("#myGrid01", data01, columns, options);

    var data02 = CreateData();
	// clone the columns and options so one grid doesn't affect the other
	grid02 = new Slick.Grid("#myGrid02", data02, columns.slice(0), jQuery.extend({}, options));
  })
</script>
</body>
</html>
